package top.toptimus.dto.accessory;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * 订单辅料耗用DTO
 */
@NoArgsConstructor
@AllArgsConstructor
@Data
public class StyleAccessoryDTO {
    //  辅料类别
    protected String subMaterialTypeId;//辅料类别id
    protected String subMaterialType;//辅料类别

    //  辅料基础属性
    protected String subMaterialSupplier;//供应商
    protected String subMaterialPicture;//图片
    protected String subMaterialNumber;//品番（供应商编码）
    protected String subMaterialCode;//辅料编码
    protected String subMaterialName;//辅料名称
    protected String subMaterialSpec;//规格

    //  辅料工艺属性
    protected String subMaterialPositionId;//位置id
    protected String subMaterialPosition;//位置
    protected String subMaterialColorId;//颜色id，十六进制码
    protected String subMaterialColor;//颜色
    protected Double subMaterialCount;//单耗（数量）
    protected String subMaterialRemarks;//备注

    public void build(StyleAccessoryDTO styleAccessoryDTO) {
        this.subMaterialSupplier = styleAccessoryDTO.getSubMaterialSupplier();
        this.subMaterialPicture = styleAccessoryDTO.getSubMaterialPicture();
        this.subMaterialNumber = styleAccessoryDTO.getSubMaterialNumber();
        this.subMaterialCode = styleAccessoryDTO.getSubMaterialCode();
        this.subMaterialName = styleAccessoryDTO.getSubMaterialName();
        this.subMaterialSpec = styleAccessoryDTO.getSubMaterialSpec();

        this.subMaterialPositionId = styleAccessoryDTO.getSubMaterialPositionId();
        this.subMaterialPosition = styleAccessoryDTO.getSubMaterialPosition();
        this.subMaterialColorId = styleAccessoryDTO.getSubMaterialColorId();
        this.subMaterialColor = styleAccessoryDTO.getSubMaterialColor();
        this.subMaterialCount = styleAccessoryDTO.getSubMaterialCount();
        this.subMaterialRemarks = styleAccessoryDTO.getSubMaterialRemarks();
    }

    /**
     * 生成批次辅料信息
     *
     * @param styleAccessoryDTO 订单辅料信息
     * @param batchQuantity     批次数量
     */
    public StyleAccessoryDTO(StyleAccessoryDTO styleAccessoryDTO, Double batchQuantity) {
        this.subMaterialTypeId = styleAccessoryDTO.getSubMaterialTypeId();
        this.subMaterialType = styleAccessoryDTO.getSubMaterialType();
        this.build(styleAccessoryDTO);
        this.subMaterialCount = this.subMaterialCount * batchQuantity;
    }
}
